<script src="../../public/js/main.js"></script>
<script src="../../routers/api.js"></script>
<script src="../../routers/admin.js"></script>{% extends 'layout.html'%}
{% block title%}用户列表{%endblock%}
{% block scripts%}
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
    $(function(){
        let $delete = $('#delete');
        $($delete).click(function (){
            window.location.href='/admin/links?page=1'
        })
    })
</script>
{%endblock%}
{% block body%}
<form class="form-inline">
    <a class="btn btn-default" href="/admin/links/add" role="button">新建链接</a>
</form>
<table class="table table-hover table-striped">

    <tr>
        <td>名称</td>
        <td>URL</td>
        <td>操作</td>

    </tr>
    {% for link in links %}
    <tr>
        <td>{{link.name}}</td>
        <td>{{link.url}}</td>
        <td>
            <a href="/admin/links/change?id={{link._id.toString()}}">更改</a>||
            <a id="delete" href="/admin/links/delete?id={{link._id.toString()}}">删除</a>
        </td>
    </tr>
    {% endfor%}
</table>
<nav aria-label="...">
    <ul class="pager">
        <li><a href="/admin/links?page={{page-1}}">上一页</a></li>
        {{page}}/{{maxPage}}
        <li><a href="/admin/links?page={{page+1}}">下一页</a></li>
    </ul>
</nav>

{% endblock%}